package com.diors.game.example.server.xmldata;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import com.diors.game.engine.arpg.scene.model.SceneLineModel;

/**
 * 场景分线Data
 * @author	darren.ouyang <ouyang.darren@gmail.com>
 * @date	2013-10-23
 * @version 1.0
 * @copyright Copyright (c) 2013, darren.ouyang
 */
@XmlRootElement(name = "lines")
@XmlAccessorType(XmlAccessType.FIELD)
public class SceneLineData 
{
	
	@XmlElement(name = "line")
	private List<SceneLineModel> list;
	
	private Map<Integer, SceneLineModel> map = new HashMap<Integer, SceneLineModel>();
	
	/**
	 * 加载xml后监听进入
	 * @param u
	 * @param parent
	 * @create	2013-9-16	darren.ouyang
	 */
	void afterUnmarshal(Unmarshaller u, Object parent)
	{
		map.clear();
		for(SceneLineModel model : list)
			map.put(model.getSecneId(), model);
				
		list = null;
		XmlDataManager.log.info("loading SceneLineData size:" + map.size());
	}
	
	public SceneLineModel getModel (int sceneID)
	{
		return map.get(sceneID);
	}
}
